package com.platform.upms.controller;

import com.platform.common.log.SystemLog;
import com.platform.common.page.Page;
import com.platform.upms.model.Log;
import com.platform.upms.model.json.Tip;
import com.platform.upms.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(value = "/log")
public class LogController {

    @Autowired
    private LogService logService;

    @RequestMapping(value = "/list")
    public String list(Page<Log> page, Model model) {
        Page<Log> list = logService.findByPage(page, new Log());
        model.addAttribute("page", list);
        return "/log/list.jsp";
    }

    @RequestMapping(value = "/deleteDataByIds")
    @ResponseBody
    @SystemLog(description = "日志批量删除")
    public Tip deleteDataByIds(Integer[] ids) {
        Tip tip = new Tip();
        try {
            logService.deleteDataByIds(ids);
        }catch (Exception e) {
            tip = new Tip(1, "删除失败");
        }
        return tip;
    }

}
